package com.lzq.his.service;

import com.lzq.his.domain.User;
import com.lzq.his.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;
import java.util.UUID;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public List<User> selectAll() {
        return userMapper.selectByExample(null);
    }


    public void deleteById(String id) {
        userMapper.deleteByPrimaryKey(Integer.parseInt(id));
    }

    public void save(User user) {
        if (user.getId() == null) {
            Random random = new Random();
            user.setId(random.nextInt());
            userMapper.insert(user);
        } else {
            userMapper.updateByPrimaryKeySelective(user);
        }
    }
}
